<?php

namespace app\model\ec;

use app\model\ModelUtils;
use think\Model;
use think\facade\Cache;

class Specification2GoodsModel extends Model
{  

    /**
     * 该表将与模型关联。
     * @var string
     */
    protected $table = 'ec_specification2goods';

    // 开启自动时间戳（默认为整型int）
    protected $autoWriteTimestamp = false;

    public static function getSpecIds($goodsId)
    {
        $cacheKey = "ec_spec_relation_{$goodsId}";
        $data = Cache::get($cacheKey);
        if ($data) {
            return $data;
        }
        $data = self::where('goods_id', $goodsId)->column('spec_id');
        Cache::set($cacheKey, $data);
        ModelUtils::cachePut('ec_specification_relation', $cacheKey);
        return $data;
    }
}
